﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Order.EntityFrameworkCore.Migrations
{
    public partial class Init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "t_order",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    Version = table.Column<long>(nullable: false),
                    OrderUniqueCode = table.Column<string>(nullable: true),
                    TotalPrice = table.Column<decimal>(nullable: false),
                    OrderStatus = table.Column<int>(nullable: false),
                    CustomerId = table.Column<string>(nullable: true),
                    CreateTime = table.Column<DateTime>(nullable: false),
                    Status = table.Column<bool>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_order", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "t_order_items",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    OrderId = table.Column<string>(nullable: true),
                    SkuPrice = table.Column<decimal>(nullable: false),
                    SkuQuantity = table.Column<int>(nullable: false),
                    ProductId = table.Column<string>(nullable: true),
                    Status = table.Column<bool>(nullable: false),
                    OrderProduct_SpuName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_order_items", x => x.Id);
                    table.ForeignKey(
                        name: "FK_t_order_items_t_order_OrderId",
                        column: x => x.OrderId,
                        principalTable: "t_order",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_t_order_items_OrderId",
                table: "t_order_items",
                column: "OrderId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_order_items");

            migrationBuilder.DropTable(
                name: "t_order");
        }
    }
}
